package com.nbsaas.boot.controller.ai;

import com.nbsaas.boot.rest.annotations.AddOperator;
import com.nbsaas.boot.rest.annotations.DeleteOperator;
import com.nbsaas.boot.rest.annotations.UpdateOperator;
import com.nbsaas.boot.rest.annotations.ViewOperator;
import com.nbsaas.boot.rest.response.ListResponse;
import com.nbsaas.boot.rest.response.PageResponse;
import com.nbsaas.boot.rest.response.ResponseObject;
import com.nbsaas.boot.rest.annotations.CreateData;
import com.nbsaas.boot.rest.annotations.UpdateData;
import com.nbsaas.boot.ai.api.domain.request.AiSessionRequest;
import com.nbsaas.boot.ai.api.domain.request.AiSessionSearch;
import com.nbsaas.boot.ai.api.domain.response.AiSessionResponse;
import com.nbsaas.boot.ai.api.domain.simple.AiSessionSimple;
import com.nbsaas.boot.ai.api.apis.AiSessionApi;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import jakarta.annotation.Resource;

/**
*  AI对话会话前端控制器
*/
@RequiresAuthentication
@RestController
@RequestMapping("/app/aiSession")
public class AiSessionAppController {


    @Resource
    private AiSessionApi aiSessionApi;


    @RequestMapping("/search")
    public PageResponse<AiSessionSimple> search(AiSessionSearch request) {
        return aiSessionApi.search(request);
    }

    @RequestMapping("/list")
    public ListResponse<AiSessionSimple> list(AiSessionSearch request) {
        return aiSessionApi.list(request);
    }

    /**
    * 添加数据
    *
    * @param request
    * @return
    */
    @CreateData
    @RequestMapping("/create")
    public ResponseObject<AiSessionResponse> create(@Validated(AddOperator.class) AiSessionRequest request) {
        return aiSessionApi.create(request);
    }

     @UpdateData
     @RequestMapping("/update")
     public ResponseObject<AiSessionResponse> update(@Validated(UpdateOperator.class) AiSessionRequest
         request) {
         return aiSessionApi.update(request);
     }

     @RequestMapping("/delete")
     public ResponseObject<?> delete(@Validated(DeleteOperator.class) AiSessionRequest request) {
        return aiSessionApi.delete(request);
     }

     @RequestMapping("/view")
     public ResponseObject<AiSessionResponse> view(@Validated(ViewOperator.class) AiSessionRequest request) {
         return aiSessionApi.view(request);
     }

  }
